package com.spring.ai;

import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class LLMTest {

    @Test
    public void testGPTDemo() {
        OpenAiChatModel model = OpenAiChatModel.builder()
                .baseUrl("http://langchain4j.dev/demo/openai/v1")
                .apiKey("demo")
                .modelName("gpt-4o-mini")
                .build();
        String answer = model.chat("你好,你是谁");
        System.out.println("结果:"+answer);
    }
    @Autowired
    private OpenAiChatModel openAiChatModel;
    //大模型通用接口
//    private ChatLanguageModel chatLanguageModel;
    @Test
    public void testGPTDemoOne() {
        String result= openAiChatModel.chat("你叫什么名字");
        System.out.println("结果为:"+result);
    }
    @Autowired
    private OllamaChatModel ollamaChatModel;
    @Test
    public void testOllamaemoRTwo() {
        String result= ollamaChatModel.chat("你叫什么名字");
        System.out.println("结果为:"+result);
    }
    @Autowired
    private QwenChatModel qwenChatModel;
    @Test
    public void testCommunityDemoR() {
        String result= qwenChatModel.chat("你叫什么名字");
        System.out.println("结果为:"+result);
    }
}
